package com.pro.controller;

import com.pro.pojo.JsMicroLog;
import com.pro.pojo.JsonData;
import com.pro.service.JsMicroLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * ClassName:JsMicroLogController
 * Package:com.pro.controller
 * Description:
 *
 * @Date:2021/12/3 上午 11:48
 * @Author: WYH
 */
@Controller
@RequestMapping("/microLog")
public class JsMicroLogController {

    @Autowired
    private JsMicroLogService jsMicroLogService;

    @RequestMapping("/getAllMicroLog")
    @ResponseBody
    public JsonData getAllMicroLog(String trueName, String createDate,Integer page, Integer limit) {
        trueName = trueName  != null  ? "%"+trueName+"%":"%%";
        createDate = createDate = createDate != null ? "%"+createDate+"%":"%%";
        List<JsMicroLog> allMicroLog = jsMicroLogService.getAllMicroLog(trueName, createDate,page,limit);
        int count = jsMicroLogService.count(trueName, createDate);
        return allMicroLog != null ? JsonData.buildSuccess(allMicroLog,count):JsonData.buildError("服务端错误");
    }

    @RequestMapping("/delMicroLog")
    @ResponseBody
    public JsonData delMicroLog(Integer logId) {
        Boolean aBoolean = jsMicroLogService.delMicroLog(logId);
        return aBoolean != false ? JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端异常");
    }
}
